{include file="public/header" /}


<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <div class="subject">
                <h3>{$Think.lang.ds_supplier}</h3>
                <h5></h5>
            </div>
            {include file="public/admin_items" /}
        </div>
    </div>
    <div class="homepage-focus" dstype="editStoreContent">
        <ul class="tab-menu">
            <li class="current">{$Think.lang.store_info}</li>
            <li>{$Think.lang.register_info}</li>
            <li>{$Think.lang.credit_num}</li>
        </ul>
        <form id="store_form" method="post">
            <input type="hidden" name="store_id" value="{$store_array.store_id}"/>
            <table class="ds-default-table">
                <!--店主账号-->
                <tr class="noborder">
                    <td class="required w120"><label class="validation"
                                                     for="store_name">{$Think.lang.store_user_name}:</label></td>
                    <td class="vatop rowform">{$store_array.member_name}</td>
                    <td class="vatop tips"></td>
                </tr>

                <!--卖家账号-->
                <tr class="noborder">
                    <td class="required w120"><label class="validation"
                                                     for="store_name">{$Think.lang.ds_seller_name}:</label></td>
                    <td class="vatop rowform">{$store_array.seller_name}</td>
                    <td class="vatop tips">{$Think.lang.store_seller_name_tips}</td>
                </tr>

                <!--运营商类型-->
                <tr class="noborder">
                    <td class="required w120"><label class="validation"
                                                     for="store_name">{$Think.lang.store_type}:</label></td>
                    <td class="vatop rowform">
                        <select name="storeclass_id" id="store_type">
                            <option value="0">请选择</option>
                            {notempty name="class_list"}
                            {foreach $class_list as $key => $val}
                            <option {$store_array.storeclass_id== $val[
                            'storeclass_id'] ? 'selected' : ''}
                            value="{$val['storeclass_id']}">{$val['storeclass_name']}</option>
                            {/foreach}
                            {/notempty}
                        </select>
                    </td>
                    <td class="vatop tips"></td>
                </tr>

                <!--区域-->
                <tr class="noborder">
                    <td class="required w120"><label class="validation" for="store_name">区域:</label></td>
                    <td class="vatop rowform">
                        <input type="hidden" id="area_ids" name="region" value="{$store_array.area_ids}">
                        <button type="button" class="btn btn-small" id="selectArea">选择区域</button>
                        <span id="area_name">
                              {notempty name="select_area_str"}
                              {$select_area_str}
                              {/notempty}
                          </span>

                    </td>
                    <td class="vatop tips"></td>
                </tr>

                <!--运营商名称-->
                <tr class="noborder">
                    <td class="required w120"><label class="validation"
                                                     for="store_name">{$Think.lang.ds_store_name}:</label></td>
                    <td class="vatop rowform"><input type="text" value="{$store_array.store_name}" id="store_name"
                                                     name="store_name" class="txt"></td>
                    <td class="vatop tips"></td>
                </tr>

                <!--开店时间-->
                <tr class="noborder">
                    <td class="w120"><label class="" for="">{$Think.lang.store_addtime}:</label></td>
                    <td class="vatop rowform">{notempty
                        name="$store_array.store_addtime"}{$store_array.store_addtime|date='Y-m-d',###}{/notempty}
                    </td>
                    <td class="vatop tips"></td>
                </tr>

                <!--有效期至-->
                <tr class="noborder">
                    <td class="w120"><label class="" for="">{$Think.lang.period_to}:</label></td>
                    <td class="vatop rowform"><input type="text" value="{$store_array.store_endtime}" id="end_time"
                                                     name="end_time" class="txt date"></td>
                    <td class="vatop tips">{$Think.lang.formart}</td>
                </tr>
                <input type="hidden" name="member_id" value="{$joinin_detail.member_id}"/>
                <!--状态-->
                <tr class="noborder">
                    <td class="w120"><label class="" for="">{$Think.lang.state}:</label></td>
                    <td class="vatop rowform onoff"><label for="store_state1"
                                                           class="cb-enable {if $store_array.store_state == '1'}selected{/if}"><span>{$Think.lang.ds_open}</span></label>
                        <label for="store_state0"
                               class="cb-disable {if $store_array.store_state == '0'}selected{/if}"><span>{$Think.lang.ds_close}</span></label>
                        <input id="store_state1" name="store_state" {if $store_array.store_state==
                        '1'}checked="checked"{/if} onclick="$('#tr_store_close_info').hide();" value="1" type="radio">
                        <input id="store_state0" name="store_state" {if $store_array.store_state==
                        '0'}checked="checked"{/if} onclick="$('#tr_store_close_info').show();" value="0" type="radio">
                    </td>
                    <td class="vatop tips"></td>
                </tr>

                <!--项目提成-->
                <tr class="noborder">
                    <td class="w120"><label class="" for="">{$Think.lang.deduct_project}:</label></td>
                    <td class="vatop rowform">
                        <select class="class-select" name='project_type'>
                            <?php if($store_array['project_type'] == 1){ ?>
                            <option value="1" checked='checked'>百分比</option>
                            <option value="2">固定加价</option>
                            <?php }else{ ?>
                            <option value="2" checked='checked'>固定加价</option>
                            <option value="1">百分比</option>
                            <?php } ?>
                            {/foreach}
                        </select></td>
                    <td class="vatop tips"></td>
                </tr>
                <tr class="noborder">
                    <td class="w120"><label class="" for="">{$Think.lang.deduct_project}:</label></td>
                    <td class="vatop rowform"><input type="text" value="{$store_array.deduct_project}"
                                                     id="deduct_project" name="deduct_project" class="txt"></td>
                    <td class="vatop tips"></td>
                </tr>

                <!--销售提成-->
                <tr class="noborder">
                    <td class="w120"><label class="" for="">{$Think.lang.deduct_market}:</label></td>
                    <td class="vatop rowform"><input type="text" value="{$store_array.deduct_market}" id="deduct_market"
                                                     name="deduct_market" class="txt"></td>
                    <td class="vatop tips"></td>
                </tr>

                <!--服务提成-->
                <tr class="noborder">
                    <td class="w120"><label class="" for="">{$Think.lang.deduct_sever}:</label></td>
                    <td class="vatop rowform"><input type="text" value="{$store_array.deduct_sever}" id="deduct_sever"
                                                     name="deduct_sever" class="txt"></td>
                    <td class="vatop tips"></td>
                </tr>

                <!--余额-->
                <tr class="noborder">
                    <td class="w120"><label class="" for="">余额:</label></td>
                    <td class="vatop rowform"><input type="text" value="{$store_array.balance}" id="balance"
                                                     name="balance" class="txt"></td>
                    <td class="vatop tips"></td>
                </tr>

                <!--关闭原因-->
                <tr class="noborder" id="tr_store_close_info">
                    <td class="w120"><label class="" for="">{$Think.lang.store_close_info}:</label></td>
                    <td class="vatop rowform"><textarea name="store_close_info" rows="6" class="tarea"
                                                        id="store_close_info">{$store_array.store_close_info}</textarea>
                    </td>
                    <td class="vatop tips"></td>
                </tr>

                <tfoot>
                <tr class="tfoot">
                    <td colspan="15"><input class="btn" type="submit" value="{$Think.lang.ds_submit}"/></td>
                </tr>
                </tfoot>
            </table>
        </form>

        <form id="joinin_form" enctype="multipart/form-data" method="post" action="{:url('Supplier/edit_save_joinin')}"
              style="display:none;">
            <input type="hidden" name="member_id" value="{$joinin_detail.member_id}"/>
            {if $joinin_detail.store_type != 1}

            <table border="0" cellpadding="0" cellspacing="0" class="store-joinin ds-default-table">
                <thead>
                <tr>
                    <th colspan="20">{$Think.lang.company_contact_information}</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <th class="w150">{$Think.lang.company_name}：</th>
                    <td colspan="20"><input type="text" class="txt" name="company_name"
                                            value="{$joinin_detail.company_name}"></td>
                </tr>
                <tr>
                    <th>{$Think.lang.company_location}：</th>
                    <td><input type="hidden" name="company_address" id="company_address"
                               value="{$joinin_detail.company_address}"></td>
                    <th>{$Think.lang.company_address}：</th>
                    <td><input type="text" class="txt w300" name="company_address_detail"
                               value="{$joinin_detail.company_address_detail}"></td>
                    <th>{$Think.lang.registered_capital}：</th>
                    <td><input type="text" class="txt w72" name="company_registered_capital"
                               value="{$joinin_detail.company_registered_capital}">&nbsp;{$Think.lang.ten_thousand}{$Think.lang.currency_zh}
                    </td>
                </tr>
                <tr>
                    <th>{$Think.lang.contact_name}：</th>
                    <td><input type="text" class="txt" name="contacts_name" value="{$joinin_detail.contacts_name}"></td>
                    <th>{$Think.lang.contact_number}：</th>
                    <td><input type="text" class="txt" name="contacts_phone" value="{$joinin_detail.contacts_phone}">
                    </td>
                    <th>{$Think.lang.e_mail}：</th>
                    <td><input type="text" class="txt" name="contacts_email" value="{$joinin_detail.contacts_email}">
                    </td>
                </tr>
                </tbody>
            </table>
            <table border="0" cellpadding="0" cellspacing="0" class="store-joinin ds-default-table">
                <thead>
                <tr>
                    <th colspan="20">{$Think.lang.business_license_information}</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <th class="w150">{$Think.lang.business_license_number}：</th>
                    <td><input type="text" class="txt" name="business_licence_number"
                               value="{$joinin_detail.business_licence_number}"></td>
                </tr>
                <tr>

                    <th>{$Think.lang.place_business_license}：</th>
                    <td><input type="hidden" name="business_licence_address" id="business_licence_address"
                               value="{$joinin_detail.business_licence_address}"></td>
                </tr>
                <tr>
                  <!--营业执照有效期-->
                    <th>{$Think.lang.validity_business_license}：</th>
                    <td><input type="text" class="txt" name="business_licence_start" id="business_licence_start" value="{$joinin_detail.business_licence_start}"> -
                        <input type="text" class="txt" name="business_licence_end" id="business_licence_end" value="{$joinin_detail.business_licence_end}">
                    </td>
                </tr>
                <tr>
                    <th>{$Think.lang.legal_scope_business}：</th>
                    <td colspan="20"><input type="text" class="txt w300" name="business_sphere"
                                            value="{$joinin_detail.business_sphere}"></td>
                </tr>
                <tr>
                    <th>{$Think.lang.business_license}<br/>{$Think.lang.electronic_version}：</th>
                    <td colspan="20">
                        {notempty name="joinin_detail.business_licence_number_electronic"}
                        <a data-lightbox="lightbox-image"
                           href="{:get_store_joinin_imageurl($joinin_detail['business_licence_number_electronic'])}">
                            <img src="{:get_store_joinin_imageurl($joinin_detail['business_licence_number_electronic'])}"
                                 height="100"/> </a>
                        <input class="w200" type="file" name="business_licence_number_electronic">
                        {/notempty}
                    </td>
                </tr>
                </tbody>
            </table>

            <table border="0" cellpadding="0" cellspacing="0" class="store-joinin ds-default-table">
                <thead>
                <tr>
                    <th colspan="20">{$Think.lang.bank_information}：</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <th class="w150">{$Think.lang.bank_name}：</th>
                    <td><input type="text" class="txt w300" name="bank_account_name"
                               value="{$joinin_detail.bank_account_name}"></td>
                </tr>
                <tr>
                    <th>{$Think.lang.company_bank_account}：</th>
                    <td><input type="text" class="txt w300" name="bank_account_number"
                               value="{$joinin_detail.bank_account_number}"></td>
                </tr>
                <tr>
                    <th>{$Think.lang.name_branch_bank}：</th>
                    <td><input type="text" class="txt w300" name="bank_name" value="{$joinin_detail.bank_name}"></td>
                </tr>
                <tr>
                    <th>{$Think.lang.location_bank_account}：</th>
                    <td colspan="20"><input type="hidden" name="bank_address" id="bank_address"
                                            value="{$joinin_detail.bank_address}"></td>
                </tr>

                </tbody>

            </table>
            <table border="0" cellpadding="0" cellspacing="0" class="store-joinin ds-default-table">
                <thead>
                <tr>
                    <th colspan="20">{$Think.lang.settlement_account_information}：</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <th class="w150">{$Think.lang.bank_name1}：</th>
                    <td><input type="text" class="txt w300" name="settlement_bank_account_name"
                               value="{$joinin_detail.settlement_bank_account_name}"></td>
                </tr>
                <tr>
                    <th>{$Think.lang.company_bank_account}：</th>
                    <td><input type="text" class="txt w300" name="settlement_bank_account_number"
                               value="{$joinin_detail.settlement_bank_account_number}"></td>
                </tr>
                <tr>
                    <th>{$Think.lang.name_branch_bank}：</th>
                    <td><input type="text" class="txt w300" name="settlement_bank_name"
                               value="{$joinin_detail.settlement_bank_name}"></td>
                </tr>

                <tr>
                    <th>{$Think.lang.location_bank_account}：</th>
                    <td><input type="hidden" name="settlement_bank_address" id="settlement_bank_address"
                               value="{$joinin_detail.settlement_bank_address}"></td>
                </tr>
                </tbody>

            </table>

            {else /}
            <table border="0" cellpadding="0" cellspacing="0" class="store-joinin ds-default-table">
                <thead>
                <tr>
                    <th colspan="6">{$Think.lang.store_and_contact_info}</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <th>{$Think.lang.company_name}：</th>
                    <td><input type="text" class="txt company_name" name="company_name"
                               value="{$joinin_detail.company_name}"></td>
                    <th>{$Think.lang.company_location}：</th>
                    <td><input type="hidden" name="company_address" id="company_address"
                               value="{$joinin_detail.company_address}"></td>
                    <th>{$Think.lang.company_address}：</th>
                    <td colspan="3"><input type="text" class="txt w300" name="company_address_detail"
                                           value="{$joinin_detail.company_address_detail}"></td>
                </tr>

                <tr>
                    <th>{$Think.lang.legal_person}：</th>
                    <td><input type="text" class="txt" name="legal_person" value="{$joinin_detail.legal_person}"></td>
                    <th>{$Think.lang.legal_person_phone}：</th>
                    <td><input type="text" name="legal_person_phone" id="company_address"
                               value="{$joinin_detail.legal_person_phone}"></td>
                    <th>{$Think.lang.contact_name}：</th>
                    <td colspan="3"><input type="text" class="txt w300" name="contacts_name"
                                           value="{$joinin_detail.contacts_name}"></td>
                </tr>
                <tr>
                    <th>{$Think.lang.contact_number}：</th>
                    <td><input type="text" class="txt" name="contacts_phone" value="{$joinin_detail.contacts_phone}">
                    </td>
                    <th>{$Think.lang.contact_phone}：</th>
                    <td><input type="text" class="txt" name="contact_legal_phone"
                               value="{$joinin_detail.contact_legal_phone}"></td>
                    <th>{$Think.lang.e_mail}：</th>
                    <td><input type="text" class="txt" name="contacts_email" value="{$joinin_detail.contacts_email}">
                    </td>
                </tr>
                </tbody>
            </table>
            <table border="0" cellpadding="0" cellspacing="0" class="store-joinin ds-default-table">
                <thead>
                <tr>
                    <th colspan="20">{$Think.lang.business_license_information}</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <th class="w150">{$Think.lang.business_license_number}：</th>
                    <td><input type="text" class="txt" name="business_licence_number"
                               value="{$joinin_detail.business_licence_number}"></td>
                </tr>
                <tr>
                    <!--
                                          <th class="w150">{$Think.lang.duty_paragraph}：</th>
                                          <td><input type="text" class="txt" name="duty_paragraph" value="{$joinin_detail.duty_paragraph}"></td></tr><tr>

                                          <th class="w150">{$Think.lang.credit_code}：</th>
                                          <td><input type="text" class="txt" name="credit_code" value="{$joinin_detail.credit_code}"></td></tr><tr> -->

                    <th>{$Think.lang.place_business_license}：</th>
                    <td><input type="hidden" name="business_licence_address" id="business_licence_address"
                               value="{$joinin_detail.business_licence_address}"></td>
                </tr>
                <tr>
                    <!--营业执照有效期-->
                    <th>{$Think.lang.validity_business_license}：</th>
                    <td><input type="text" class="txt" name="business_licence_start" id="business_licence_start"
                               value="{$joinin_detail.business_licence_start}"> - <input type="text" class="txt"
                                                                                         name="business_licence_end"
                                                                                         id="business_licence_end"
                                                                                         value="{$joinin_detail.business_licence_end}">
                    </td>
                </tr>
                <tr>
                    <th>{$Think.lang.legal_scope_business}：</th>
                    <td colspan="20"><input type="text" class="txt w300" name="business_sphere"
                                            value="{$joinin_detail.business_sphere}"></td>
                </tr>
                <tr>
                    <th>{$Think.lang.business_license}<br/>{$Think.lang.electronic_version}：</th>
                    <td colspan="20">
                        {notempty name="joinin_detail.business_licence_number_electronic"}
                        <a data-lightbox="lightbox-image"
                           href="{:get_store_joinin_imageurl($joinin_detail['business_licence_number_electronic'])}">
                            <img src="{:get_store_joinin_imageurl($joinin_detail['business_licence_number_electronic'])}"
                                 height="100"/> </a>
                        <input class="w200" type="file" name="business_licence_number_electronic">
                        {/notempty}
                    </td>
                </tr>
                </tbody>
            </table>


            <table border="0" cellpadding="0" cellspacing="0" class="store-joinin ds-default-table">
                <thead>
                <tr>
                    <th colspan="2">{$Think.lang.store_alipay_info}：</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <th>{$Think.lang.bank_account_name}：</th>
                    <td><input type="text" class="txt w300" name="settlement_bank_account_name"
                               value="{$joinin_detail.settlement_bank_account_name}"></td>
                </tr>
                <tr>
                    <th>{$Think.lang.bank_account_number}：</th>
                    <td><input type="text" class="txt w300" name="settlement_bank_account_number"
                               value="{$joinin_detail.settlement_bank_account_number}"></td>
                </tr>

                <tr>
                    <th>{$Think.lang.bank_name}：</th>
                    <td><input type="text" class="txt w300" name="settlement_bank_name"
                               value="{$joinin_detail.settlement_bank_name}"></td>
                </tr>

                <tr>
                    <th>{$Think.lang.bank_address}：</th>
                    <td><input type="text" class="txt w300" name="settlement_bank_address"
                               value="{$joinin_detail.settlement_bank_address}"></td>
                </tr>
                </tbody>
                <script>

                </script>

            </table>
            {/if}
            <div><input class="btn join_submit" type="submit" value="{$Think.lang.ds_submit}"/></div>
        </form>
        <form id="credit_num_form" action="{:url('supplier/deduct')}" method="post" style="display:none;">
            <input type="hidden" name="store_id" value="{$store_array.store_id}"/>
            <table class="ds-default-table">
                <tbody>
                <tr>
                    <td colspan="2" class="required"><label class="validation" for="store_name">{$Think.lang.credit_num}:</label>
                    </td>
                </tr>
                <tr class="noborder">
                    <td class="vatop rowform"><input type="text" value="{$store_array.credit_num}" id="credit_num"
                                                     name="credit_num" class="txt"></td>
                    <td class="vatop tips"></td>
                </tr>

                <tr>
                    <td colspan="2" class="required"><label class="validation" for="credit_day">{$Think.lang.credit_day}:</label>
                    </td>
                </tr>
                <tr class="noborder">
                    <td class="vatop rowform"><input type="text" value="{$store_array.credit_day}" id="credit_day"
                                                     name="credit_day" class="txt"></td>
                    <td class="vatop tips"></td>
                </tr>
                <tr>
                    <td colspan="2" class="required"><label class="validation" for="invocie_money">{$Think.lang.invocie_money}:</label>
                    </td>
                </tr>
                <tr class="noborder">
                    <td class="vatop rowform"><input type="text" value="{$store_array.invocie_money}" id="invocie_money"
                                                     name="invocie_money" class="txt"></td>
                    <td class="vatop tips"></td>
                </tr
                >
                <tr>
                    <td colspan="2" class="required"><label class="validation" for="debt_money">{$Think.lang.debt_money}:</label>
                    </td>
                </tr>
                <tr class="noborder">
                    <td class="vatop rowform"><input type="text" value="{$store_array.debt_money}" id="debt_money"
                                                     name="debt_money" class="txt"></td>
                    <td class="vatop tips"></td>
                </tr>

                </tbody>
            </table>
            <div><input class="btn" type="submit" value="{$Think.lang.ds_submit}"/></div>
        </form>
    </div>
</div>

<div class="list" style='display:none;margin-left: 20px;' id="allsa">
    <input style="padding-right: 8px;" type="checkbox" id="checkboxs" name="checkall">全选
    <?php foreach($top_area as $k=>$v){ ?>
    <div class="top">

    <span style="font-family: 'dtreefont' !important;font-size: 16px;font-style: normal;-webkit-font-smoothing: antialiased;-webkit-tap-highlight-color: rgba(0,0,0,0);"
          class='select_choose dtreefont dtree-icon-jia dtree-theme-dtreefont dtree-theme-ficon' data-spread="close">
    </span>
        <input style="margin-right: 8px;" type="checkbox" value="<?php echo $v['area_id']; ?>" class="top" area_deep="1"
               area_name="<?php echo $v['area_name']; ?>" ids="<?php echo $v['last_ids']; ?>">
        <b><?php echo $v['area_name']; ?></b></br>
        <div class="sec<?php echo $v['area_id']; ?>" style='padding-left:20px; margin:10px;'></div>
    </div>
    <?php }?>
</div>
<link rel="stylesheet" href="{$Think.PLUGINS_SITE_ROOT}/js/jquery.lightbox/css/lightbox.min.css">
<script src="{$Think.PLUGINS_SITE_ROOT}/js/jquery.lightbox/js/lightbox.min.js"></script>
<script type="text/javascript">
    $(function () {
        function nosubmit(c) {
            $(c).attr('disabled', 'true');
            $(c).css('background', '#eee');
        }

        function delnosubmit(c) {
            $(c).removeAttr('disabled');
            $(c).css('background', '');
        }

        // 用户名检测
        $('[name="settlement_bank_account_name"]').blur(function () {
            var val = $(this).val();
            if (!val) {
                nosubmit('.join_submit');
                layer.msg('银行开户名必须填写');
            } else {
                delnosubmit('.join_submit');
            }
            if (val.length <= 2) {
                nosubmit('.join_submit');
                layer.msg('银行开户名不能小于两个字符');
            } else {
                delnosubmit('.join_submit');
            }
            var pattern = /^[0-9]*$/;
            if (pattern.test(val)) {
                nosubmit('.join_submit');
                layer.msg('银行开户名不能为纯数字')
            } else {
                delnosubmit('.join_submit');
            }

        })
        // 银行卡位数
        $('[name="settlement_bank_account_number"]').blur(function () {
            var val = $(this).val();
            /**
             * 百度知道
             * 1、15位存折账号；
             2、16位卡号：有银联或VISA/MASTERCard标志的（包括普通一卡通、银联金卡/葵花卡、国际借记卡、IC卡、M+卡等）；
             3、12位老卡：较早开户的账户，4位城市区号+8位账号，如城市区号不足4位，首位以0补足；
             4、19位卡号：TOUCH卡（现已停止使用一卡通开通手机TOUCH卡）
             */
            if (val.length < 12 || val.length > 19) {
                layer.msg('请输入正确的银行卡号');
            }
        })
        $("#company_address").ds_region();
        $("#business_licence_address").ds_region();
        $("#bank_address").ds_region();
        $("#settlement_bank_address").ds_region();
        $('#end_time').datepicker({dateFormat: 'yy-mm-dd'});

        /*更换成可以选择月份 年份的时间控件*/
        /*$('#business_licence_start').datepicker({dateFormat: 'yy-mm-dd'});
        * $('#business_licence_end').datepicker({dateFormat: 'yy-mm-dd'});
        * */
        $('#business_licence_start').datepicker({dateFormat: 'yy-mm-dd',   changeMonth: true,
            changeYear: true});
        $('#business_licence_end').datepicker({dateFormat: 'yy-mm-dd',   changeMonth: true,
            changeYear: true});
        $('input[name=store_state][value={$store_array.store_state}]').trigger('click');


        $('#store_form').validate({
            errorPlacement: function (error, element) {
                error.appendTo(element.parentsUntil('tr').parent().prev().find('td:first'));
            },
            rules: {
                store_name: {
                    required: true,
                    remote: "{:url('Supplier/ckeck_store_name',['store_id'=>$store_array.store_id])}"
                }
            },
            messages: {
                store_name: {
                    required: '{$Think.lang.please_input_store_name}',
                    remote: '{$Think.lang.store_name_exists}'
                }
            }
        });
        $('#joinin_form').validate({
            errorPlacement: function (error, element) {
                error.appendTo(element.parentsUntil('tr').parent().find('td:last'));
            },
            rules: {
                business_licence_start: {
                    required: true,
                },
                business_licence_end: {
                    required: true,
                }
            },
            messages: {
                business_licence_start: {
                    required: '{$Think.lang.business_licence_start_required}',
                },
                business_licence_end: {
                    required: '{$Think.lang.business_licence_start_required}',
                }
            }
        });


        $('div[dstype="editStoreContent"] > ul').find('li').click(function () {
            $(this).addClass('current').siblings().removeClass('current');
            var _index = $(this).index();
            var _form = $('div[dstype="editStoreContent"]').find('form');
            _form.hide();
            _form.eq(_index).show();
        });
        // todo 选择区域

        // 获得选中ID
        function getItems() {
            /* 获取选中的项 */
            var items = '';
            $('.checkboxs:checked').each(function () {
                items += this.value + ',';
            });
            if (items != '') {
                items = items.substr(0, (items.length - 1));
            } else {
                // layer.alert('请选择要操作的数据', {icon: 2})
            }
            return items;
        }

        $(document).on('click', '#checkboxs', function () {
            if ($(this).prop('checked')) {
                $(".top").find('input:checkbox').prop("checked", true);
            } else {
                $(".top").find('input:checkbox').prop("checked", false);
            }

        });

        // TODO 区域选择弹框
        $(document).on('click', '#selectArea', function () {
            ids_str = getItems();
            $(this).next().empty();
            id = $(this).parent().parent().attr('data-id');
            $("#area_id_list").attr('data_name', '');
            var $list = $('.list');

            obj = $(this);
            layer.confirm('', {
                title: '销售区域选择',
                type: 1,
                area: ['900px', '750px'],
                fixed: false,
                maxmin: true,
                btn: ['确认', '取消'],
                content: $list,
            }, function () {
                var chk_value = [];
                var chk_name = [];
                $('input[type="checkbox"]:checked').each(function () {
                    // if ($(this).attr('ids')) {
                    //     chk_value.push($(this).attr('ids'));
                    // }
                    chk_value.push($(this).val());
                    // console.log($(this).attr('area_name'));
                    chk_name.push($(this).attr('area_name'))
                });
                for (i in chk_name) {
                    if (!chk_name[i]) {
                        chk_name.slice(i, 1);
                    }
                }
                chk_name = chk_name.join(',');
                var ids = chk_value.join(',');

                $('#area_ids').val(ids);
                console.log($('#area_ids').val())


                var html = "";
                html += '已选择区域：' + chk_name;
                var name = $("#area_id_list").attr('data_name');

                // html+="<input type='hidden' name='area_id' value='"+chk_value+"' id='area_id_list' >";
                // html+="<input type='hidden' name='area_name' value='"+name+"'>";

                obj.next().text(html);
                layer.closeAll();


            });

        });

        $(document).on('click', '.select_choose', function () {
            var choose_id = $(this).next().val();
            var obj = $(this);
            $.ajax({
                type: 'POST',
                url: "{:url('Supplier/ajax_area')}",
                cache: false,
                data: {choose_id: choose_id},
                dataType: 'json',
                success: function (data) {
                    var htmls = '';
                    $.each(data, function (k, v) {
                        if (v.area_deep != 3) {
                            htmls += '<span class="select_choose select_choose dtreefont dtree-icon-jia dtree-theme-dtreefont dtree-theme-ficon"></span><input type="checkbox"  area_deep="' + v.area_deep + '" value="' + v.area_id + '" ids="' + v.last_ids + '" area_name="' + v.area_name + '"> ' + v.area_name + ' <div class="last' + v.area_id + '" style="padding-left:20px; margin:10px;"></div>';
                        } else {
                            htmls += '<i class="dtree-icon-shuye1 dtreefont-special dtree-theme-dtreefont dtree-theme-icon"></i>' + '<input type="checkbox" id="p3"  value="' + v.area_id + '"    area_deep="' + v.area_deep + '" area_name="' + v.area_name + '" >' + v.area_name;
                        }
                    });
                    if ($(".sec" + choose_id).length > 0) {
                        $(".sec" + choose_id).html(htmls);
                        // obj.html('<span class="area_hidden dtree-theme-dtreefont dtree-theme-ficon dtreefont dtree-icon-jian"></span>');
                        obj.attr("class", "area_hidden dtree-theme-dtreefont dtree-theme-ficon dtreefont dtree-icon-jian");
                    } else {
                        $(".last" + choose_id).html(htmls);
                        //obj.html('<span class=" area_hidden dtree-theme-dtreefont dtree-theme-ficon dtreefont dtree-icon-jian"></span>');
                        obj.attr("class", "area_hidden dtree-theme-dtreefont dtree-theme-ficon dtreefont dtree-icon-jian");
                    }
                    if (obj.next().prop('checked')) {
                        obj.next().parent('div').find('input:checkbox').prop('checked', true);
                    } else {
                        $('input[name="checkall"]').prop('checked', false);
                        obj.next().parent('div').find('input:checkbox').prop('checked', false);
                    }
                }
            })
        });

        $(document).on('click', '.area_hidden', function () {
            var choose_id = $(this).next().val();
            $(".sec" + choose_id).empty();
            $(".last" + choose_id).empty();
            var obj = $(this);
            //  obj.html('<span class="select_choose dtree-icon-jia dtree-theme-dtreefont dtree-theme-ficon"></span>');
            obj.attr("class", "select_choose dtree-icon-jia dtree-theme-dtreefont dtree-theme-ficon");
        });

        $(document).on('click', 'input:checkbox', function () {
            if ($(this).attr('area_deep') == 2) {
                if ($(this).prop('checked')) {
                    $(this).parent('div').find('input:checkbox').prop('checked', true);

                    var area_name = $(this).parent('div').parent('div').find('input[type="checkbox"]').first().next().html();
                    if ($("#area_id_list").attr('data_name').indexOf(area_name) >= 0) {

                    } else {
                        // $("#"+id+"").attr('data_name','');
                        var new_name = $("#" + id + "").attr('data_name') + ',' + area_name;
                        $("#area_id_list").attr('data_name', new_name);
                    }


                } else {
                    $('input[name="checkall"]').prop('checked', false);
                    $(this).parent('div').find('input:checkbox').prop('checked', false);
                    $(this).parent('div').parent('div').find('input:checkbox').prop('checked', false);
                }
            } else if ($(this).attr('area_deep') == 1) {
                if ($(this).prop('checked')) {
                    $(this).parent('div').find('input:checkbox').prop('checked', true);

                    var area_name = $(this).parent('div').find('input[type="checkbox"]:checked').first().next().html();
                    if ($("#area_id_list").attr('data_name').indexOf(area_name) >= 0) {
                    } else {
                        // $("#"+id+"").attr('data_name','');
                        var new_name = $("#area_id_list").attr('data_name') + area_name + ',';

                        $("#area_id_list").attr('data_name', new_name);
                    }


                } else {
                    $('input[name="checkall"]').prop('checked', false);
                    $(this).parent('div').find('input:checkbox').prop('checked', false);

                }

            } else {

                if (!$(this).prop('checked')) {
                    $('input[name="checkall"]').prop('checked', false);
                    $(this).parent('div').parent('div').find('input:checkbox').first().prop('checked', false);
                    $(this).parent('div').parent('div').parent('div').find('input:checkbox').first().prop('checked', false);
                } else {
                    var area_name = $(this).parent('div').parent('div').parent('div').find('input[type="checkbox"]').first().next().html();

                    if ($("#area_id_list").attr('data_name').indexOf(area_name) >= 0) {
                    } else {
                        //   $("#"+id+"").attr('data_name','');
                        var new_name = $("#area_id_list").attr('data_name') + ',' + area_name;

                        $("#area_id_list").attr('data_name', new_name);
                    }


                }


            }

        });

    });
</script>
